/**
 * 判断两个日期之间是不是连续的交易日
 * author by lengdh
 * 2017-12-05
 */
create or replace function is_conti_weekday(date, date) returns boolean as $$
declare
  e date := $1;
  s date := $2;
begin
  if e < s then
	return false;
  end if;
  --18年元旦处理
  IF e=date'20180102' AND s=date'20171229'THEN
  	RETURN TRUE;
  END IF;

  if date(e)-date(s) = 1 then
 	  return true;
  elseif extract(isodow from e) = 1 and  extract(isodow from s) = 5  and  date(e)-date(s) = 3 then
      return true;
  else 
      return false;
  end if;
end;
$$ language plpgsql strict;